<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="./css/api.css" rel="stylesheet"/>
  <link href="./css/element.css" rel="stylesheet"/>
  <link href="./css/base.css" rel="stylesheet"/>
  <title>人才管理系统</title>
</head>
<body>
  <div id="vm" v-cloak>

  </div>
  <script type="text/javascript" src="./script/vue.js"></script>
  <script type="text/javascript" src="./script/element.js"></script>
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./js/base.js"></script>
  <script>
  apiready = function () {
    api.addEventListener({
        name: 'loginsucc'
    }, function(ret, err) {
        api.setFrameGroupIndex({
            name: 'INDEXGROUP',
            index: 0
        });
        var NVTabBar = api.require('NVTabBar');
        NVTabBar.setSelect({
            index: 0,
            // selected: true,
            // icons:['fs://res/gif1.png','fs://res/gif2.png','fs://res/gif3.png','fs://res/gif4.png','fs://res/gif5.png','fs://res/gif6.png']
        });
    });
    // $api.setStorage('usertoken', '');
    vm.opennav()
    vm.openmaingroup()
    // console.log($api.getStorage('usertoken'));

    if($api.getStorage('usertoken')==undefined || $api.getStorage('usertoken')==''){
      api.openWin({
          name: 'gologin',
          url: './login.html',
          pageParam: {
              name: 'test'
          }
      });
    }

  }

    var vm = new Vue({
      el:'#vm',
      data(){
        return{

        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;

      },
      methods: {
        // 打开底部导航条
        opennav:function(){
          var NVTabBar = api.require('NVTabBar');
          NVTabBar.open({
              styles: {
                  bg: '#fff',
                  // bg:"widget://image/NVTabBar/tabbar_bg.png",
                  h: 60,
                  dividingLine: {
                      width: 1,
                      color: '#f5f5f5'
                  },
                  badge: {
                      bgColor: '#ff0',
                      numColor: '#fff',
                      size: 6.0,
                      centerX: 40,
                      centerY: 6
                  }
              },
              items: [{
                      w: api.winWidth / 3.0,
                      bg: {
                          marginB: 0,
                          image: 'rgba(0,0,0,0)'
                      },
                      iconRect: {
                          w: 25.0,
                          h: 25.0,
                      },
                      icon: {
                          normal: 'widget://images/tab11.png',
                          highlight: 'widget://images/ta1.png',
                          selected: 'widget://images/tab1.png'
                      },
                      title: {
                          text: '招聘',
                          size: 12.0,
                          normal: '#B6B6B6',
                          selected: '#EE1C1C',
                          marginB: 6.0
                      }
                  },
                  // {
                  //     w: api.winWidth / 5.0,
                  //     bg: {
                  //         marginB: 0,
                  //         image: 'rgba(0,0,0,0)'
                  //     },
                  //     iconRect: {
                  //         w: 25.0,
                  //         h: 25.0,
                  //     },
                  //     icon: {
                  //         normal: 'widget://images/tab22.png',
                  //         highlight: 'widget://images/tab2.png',
                  //         selected: 'widget://images/tab2.png'
                  //     },
                  //     title: {
                  //         text: '校招',
                  //         size: 12.0,
                  //         normal: '#B6B6B6',
                  //         selected: '#EE1C1C',
                  //         marginB: 6.0
                  //     }
                  // },
                   {
                      w: api.winWidth / 3.0,
                      bg: {
                          marginB: 0,
                          image: 'rgba(0,0,0,0)'
                      },
                      iconRect: {
                          w: 25,
                          h: 25,
                      },
                      icon: {
                          normal: 'widget://images/tab33.png',
                          highlight: 'widget://images/tab3.png',
                          selected: 'widget://images/tab3.png'
                      },
                      title: {
                          text : '工作台',
                          size: 12.0,
                          normal: '#B6B6B6',
                          selected: '#EE1C1C',
                          marginB: 6.0
                      }
                  },
                  // {
                  //     w: api.winWidth / 5.0,
                  //     bg: {
                  //         marginB: 0,
                  //         image: 'rgba(0,0,0,0)'
                  //     },
                  //     iconRect: {
                  //         w: 25.0,
                  //         h: 25.0,
                  //     },
                  //     icon: {
                  //         normal: 'widget://images/tab66.png',
                  //         highlight: 'widget://images/tab6.png',
                  //         selected: 'widget://images/tab6.png'
                  //     },
                  //     title: {
                  //         text: '培训',
                  //         size: 12.0,
                  //         normal: '#B6B6B6',
                  //         selected: '#EE1C1C',
                  //         marginB: 6.0
                  //     }
                  // },
                  {
                      w: api.winWidth / 3.0,
                      bg: {
                          marginB: 0,
                          image: 'rgba(0,0,0,0)'
                      },
                      iconRect: {
                          w: 25.0,
                          h: 25.0,
                      },
                      icon: {
                          normal: 'widget://images/tab55.png',
                          highlight: 'widget://images/tab5.png',
                          selected: 'widget://images/tab5.png'
                      },
                      title: {
                          text: '我的',
                          size: 12.0,
                          normal: '#B6B6B6',
                          selected: '#EE1C1C',
                          marginB: 6.0
                      }
                  }],
              selectedIndex: 0
          }, function(ret, err) {
              if(ret.eventType == "click" && ret.index == 0){
                api.setFrameGroupIndex({
                    name: 'INDEXGROUP',
                    index: 0
                });
              }
              if(ret.eventType == "click" && ret.index == 1){
                api.setFrameGroupIndex({
                    name: 'INDEXGROUP',
                    index: 1
                });
              }
              if(ret.eventType == "click" && ret.index == 2){
                api.setFrameGroupIndex({
                    name: 'INDEXGROUP',
                    index: 2
                });
              }
              if(ret.eventType == "click" && ret.index == 3){
                api.setFrameGroupIndex({
                    name: 'INDEXGROUP',
                    index: 3
                });
              }
              if(ret.eventType == "click" && ret.index == 4){
                api.setFrameGroupIndex({
                    name: 'INDEXGROUP',
                    index: 4
                });
              }
          });

        },
        openmaingroup:function (){
          var frames = [{
            name:"tab1",
            url:"./tab1.html",
            bounces:false,
            bgColor : 'rgb(255,255,255)'
          },
          // {
          //   name:"tab2",
          //   url:"tab2.html",
          //   bounces:false,
          //   bgColor : 'rgb(255,255,255)'
          // },
          {
            name:"tab3",
            url:"tab3.html",
            bounces:false,
            bgColor : 'rgb(255,255,255)'
          },
          // {
          //   name:"tab4",
          //   url:"tab4.html",
          //   bounces:false,
          //   bgColor : 'rgb(255,255,255)'
          // },
          {
            name:"tab5",
            url:"tab5.html",
            bounces:false,
            bgColor : 'rgb(255,255,255)'
          }];
          // $api.setStorage('forXT', api.safeArea.top);
          // $api.setStorage('forXB', api.safeArea.bottom);
          // var forXB = $api.getStorage('forXB');
          // var forXB = 'margin-bottom:'+parseInt(forXB-5)+'px'
          // var footer = $api.byId('nav');
          // $api.css(footer,forXB)
          // $api.fixStatusBar(footer);
          // var nav = $api.offset(footer);
          // // $api.setStorage('footerH', nav.h);
          // var frameH = api.winHeight - nav.h+17;//frame的高度为当前window高度减去header和footer的高度
          api.openFrameGroup({
              name: 'INDEXGROUP',
              bgColor:'rgb(255,255,255)',
              scrollEnabled: false,
                  rect: {
                      x: 0,
                      y: 0,//$api.dom('header').offsetHeight,
                      w: api.winWidth,
                      h: api.winHeight-60
                      //marginLeft:0,
                      //marginTop:api.safeArea.top,
                      //marginBottom:api.safeArea.bottom,
                      //marginRight:0
                  },
                  index: 0,
                  frames: frames,
                  reload:true,
                  preload:1
              }, function (ret, err) {
                if(ret){

                }
            });
            // $api.setStorage('headerH',$api.dom('header').offsetHeight);
      }
      }
    })
  </script>
</body>
</html>
